Fixed memory leak in custom uri handler.

Added also some warning message if the handler could not be called.