Backport error handling changes from 0.9.36 to 0.9.33 and fix post handler hooking in both versions