Refactor Cernel with almost no temporary variables