Changed the buffer thread logic - BIG commit.