Sort stops, handle ajax errors