switched to self::
added correct error codes
added "accept header" support