Fixed some typos, cleaned up code