Authentication bugs fixed