Remove trailing whitespace.
unsafe Ptr functionality can be found in Foreign.ForeignPtr.Unsafe
Use explicit imports from Foreign module
Use CPP to ensure compilation on GHC 7.0.x

Foreign.Unsafe was only introduced in later GHC versions and made mandatory
after GHC 7.6.
Get rid of 'MonoPatBinds deprecated' warnings.