Fixed some stuff and clean some stuff up.
Changed some things to atomicWriteIORef instead of writeIORef>