Small fixes to the sessions, database and permission plugin.