Added regex to checkSessions middleware and a few fixes