numerous minor bugfixes