Added missing docblocks, did small refactoring