Completly refactor code so session configuration has less boiler plate
code.