Code cleanup and typos