Fixed various filtering and sorting bugs