Add some documentation and rename/refactor some methods