fixed a few bugs from the last merge