Docs and better validation
Added some docs and refactored