Finishes flash.

Adds test for flash and refactors session.