Various bug fixes and changes.