The canvas and overlays seem to work perfectly now. The recalculateSize function needs some cleanup though.