Structuring the code and cleaning code

Commented code are removed to new file for reference.