Refactor and addjust code format.