Added environment utilities. Tidied.