Bugfix: make buffer grow correctly