Fix various bugs in global newdecl support.