Big refactor to extract map and list view common

Also adds sorting to the list view