Code Cleaning and Bugfixes.