Plug some leaks, calls back with error when empty uri/script.