fixing a few bugs caused by refactoring without tests