Various coding style improvements.
Bugfixes