Functions and core rewrite