Update unsafePerformIO used to compile with GHC 7.8

Foreign.unsafePerformIO was deprecated and causing things to not compile.
use -fPIC so shared libs work correctly