Fixing more cast issues
Updating defines
Updating comments