Comprehensive bugfixing.