Update documentation, minor refactoring