cleanup and optimizations for the random movement, comments