fix bugs for raw2adm.py; try to reduce the running overhead