Mac Fixes

Fixed a few errors for the Mac version, and fixed a potentially
dangerous casting.