Patches copied from OwlNest