refactor alerts and flashes to be used in a more flexible fashion