Various bug fixes and renames.