Made session stuff into a plugin, other tweaks