Grouping, sorting and code cleanup
api changes