Convert to work with composite primary keys

This is just the first try, it may not work 100% yet!