Code cleanup and bugfixes.