Misc code reshuffle
Created by: evelikov
Pure code motion - no functional changes intended.
- stop mixing functions and sequential (?) code - keep functions at the top, everything else at the bottom
- separate between user-selectable options and internal variables - the
setupmovement - couple other nitpicks