Fixed a few bugs