Remove silly print
Added errorcode to dieWithError
Use proper HTTP error codes