split compile function (for better or worse)