Basic multi-instance support

Also fixes a few minor issues