Lots of bug fixes and changes.