comprehensive specification
tests and bug fixes