light refactoring; improved documentation