Moved session setup to a place where it works