Code cleanup and typo fix