Credit @0xced for #4598