Fixed double redirects when returning from scripts (thanks iostream)