Various fixes for signature encoding and insert logic