Improvements and tests.