cleaned up code, fixed typos