Refactor load_session_info

I've kept the spirit of your change but moved some things around for easier grokking. It seems to work on my end but I would appreciate it if you would eyeball this and test it in your environment.