Major bugfix when buffer max size is exceeded