Create proper documentation and refactor