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
Merge pull request #1 from mika/master

Redirect error messages to stderr and use proper exit code