Add constructor and move session handling to custom method