Nii - some clean up and refactor