Code cleanup
General Bugfixes