Fixed missing end; Fixed Flag Attachment indentation; Removed deprecated code