added Procedure SecurityGenHelper_AppendCheck and modified all generation procedures so that it uses it instead of keeping repetitive code in it