Changed all process.nextTick to setImmediate.
BUGFIX! Continue to emit line events until buffer is empty.
BUGFIX! Added guard to make sure only one end event is fired.