Code cleanup and fixed typos