And yet another implementation. This one has a chance to actually being correct. It currently is only for inserts and requires refactoring.