Fixed context generation for template, added flash msg