Library, tests and documentation improvements

v 4.0.1