Fixed sorting buffer issues