More work on inventory stuff, and fix all the broken merge stuff