added flash messages visibility; minor code polishing