Server crashes if there is no session in db. Some code moved inside or outside transactions.
Trying to reduce the amount of db queries.