Rewrite some functions.