Replace MVar with IORef and MVar lock

I've replaced the Counter newtype, which worked with an MVar. The new Counter data works with an IORef, with an MVar as lock.