Issue #181 cleanup and better command handling