fix for a few bugs