Improved <on save> functionality