Added max option and some bugfixes
Improved documentation and examples