Fix broken Javascript and sessions controller code