Migration from StateT to ReaderT + IORef

This change was made to easily handle cases with asynchronous exceptions
arising in IO sections of the code.
This allows access to the latest state even in exception handlers.
Merge pull request #7 from benjamin-surma/ioref_migration

Migration from StateT to ReaderT + IORef