implementing rest of commands without recursive dependency management
Fixing a bug and some refactoring to improve readability.