Small fixes to the order of commands and session handling