factor codes in history.* and move it to funcnode.*