still refactoring, plus documentation additions