tweaked parameters, code cleanup, and put in a safegaurd against too many buffered messages