Splits ugly command processing code into a dispatch for different methods. Fixes up some issues with incorrect model usage and other bugs.