Fixes for sorting