Improved session creation.

This fixes #144