code cleanup and motion improvement