Refactor tons of code and implement some more commands