Adds documentation, refactors and adds require