Refactored how flash messages are created and used.