added internal fields and sanity check for environment