optimize entities query; draw rects in debug mode by default