fix buffer size problems