Added comment folding and refactored the code.