Fixed a few bugs and made some corrections