Merging PersistentSession branch from @sirhcwolf