Bug fixes and minor improvements.