Rewrite getInsts() to be non-recursive and fix bugs