Added commands and fixed stuff.

Added commands, fixed issues with logging and made the code readable.