array size fix by ztm and minor cleanup