check for, and assign defer method to the right spot depending on environment.
Merge pull request #792 from silverbucket/bug/global_fix

check for, and assign defer method to the right spot depending on enviro...
update release/head with latest
apply newline