Added status code handler.

Plus a couple of other stuff