Major overhaul that finally has the whole thing working. Look into lib-noir to handle sessions.