Fixed a few bugs with authorization and null ref checks