Some fixes in authentication