Modify code to fit NII

If this PR includes unnecessary patches, please reject this PR.