cleanup and bugfix (which is sort of a feature)