General bugfixes and enhancements.