Many fixes and extensions to the wrapper, particuarly the inclusion of duplicate key support