improve buffering and add tweaking parameters