modified header files and fix wrong rank assignment