Reimplemented co-routine low-level logic using composition (fixes #16)