Some work on overlay

-Move some work to model-side
-Change method for sorting