Bug Fixes

Fixed various miscastings and typos.