Added improved authorization handling.