added buffer size control, needs limits!