De-form environmental scan

Also correct closing form tags left hanging because of bad logic.