Add flash and message updates. Refactor code.