Major refactoring of basic mechanics.