Refactor + support Mac and ts_paint.