minor cleanup and bugfixes.