Improvements and tests