Re-apply patch 25 with compatibility for patch 24