added some documentation
clean up due to better handling of special cases
more testcases