Make MessageHandler and Session have a type parameter