Cleaned up code and changed some minor things