Some refactoring and more inline docu