Added some small refactorings and some comments.