created function library and initial fixes