Script fixes to work in more environments and catch failures