Code cleanup and motor timeout added