Major refactoring
Improve docs