Added documentation comments

+ some small refactorings

Change-Id: I7991dfd18b6920f2e6a5d1cb21b010798f3c78c3