Fixed a few bugs here and there