Modified the method in which flash messages are being handled.