Added logic to create stack rules.