More flexible upgrade routine.
Use an action hook for rule flushing