Fix major issue with coroutines that caused subtle bugs

* Issues #47, #48, #36, #30, #26 all affected
* Still needs tidying up, scheduler could be simplified further