Fixed a few bugs and made a few more improvements