Bug fixes and small improvements.