Bug and authentication fixes