fixes a few bugs