fix buffer problems