Split up message types, added exit codes, basic command handling.
close once, handleMsg api consistency.