code clean up and general typo fixing