Split runCommand into it's own function

Splits loading state and writing events from the actual
command handling.