Small bug fixes, new tests, lots of docs