enhanced motor handling, bug fixes, initial optimization code