Extract commands into their own class.

Instead of using hashes, extract commands into a separate class.