fixes and documentation
more refactoring
more refactoring