Make it properly work with sync and async, improve session handling.