Adding comments and small refactors.