Bugfix: insert was not working correctly for some specific cases.