Redirect error messages to stderr and use proper exit code

'-1' is not a valid exit code, see e.g.
http://tldp.org/LDP/abs/html/exitcodes.html