Refactor, comment and var clean up