Made user thread handling in buffer more sane and more bulletproof.