cleanup and minor bugfix