Revamp insertion code.