Changes to fix buffering that I forgot to commit with previous patch.