Refactoring and add hessian related func. Not finished yet but committed for remote check/work.