Code refactoring.
Added some comments.