Code refactoring, added new commands, removed debug code