Rewrote the core library. We need to create a state monad to let the connection work again though