fixes issues with unfreed buffer