Organize command dispatch.
Trap failures to clean environment.