Some bug fixes and renaming.