Refactoring, added new subcommands, and some nms