loads of fixes and enhancements