Fixed filtering, added sorting and validation.