Fixes #1 and #4

The setImmediate (#4) fixed also a huge problem with loosing some lines if you try to pause and resume after every line.