Fixed up a few bugs