Extract widget and session code to app itself.