Fixes many bugs in login and adds flash messages to site