Code cleanup and more

Improved exception handling.
Some bugfixes.
Refactoring in commands-module command-base class.