Fixed a lot of bugs and handled ajax for non logged in users