Issue 1: fixed by 1) moving return traps to outside of case (bug); 2) running script in subshell