Fixed a few errors in the code