Update namtive code and performa some refactoring.