new bug fixes

some changes as suggested by Niki were incorporated