Finalised documentation + refactored some code