Fixed problem pointed out by jeppe with buffer size being rounded up when not needed