Readded some code cleanup from the convexareas branch