added docs and refactored some stuff