Added sub problem structures and sorting functions