more refactoring - added chain of responsibility pattern for commands as well as some other tidying