bugfixes 0.5.2 and cleanup