Updated token handling in buffered I/O. Fixes #159.