Re-organize code for better readability
Fix mistyped comments.