Fixed a few existing bugs