Rewrite boundary functions.