Fixed missing variables in some close functions and standardized z-indexes