Fix buffer load algorithm