Reorganize and fix enough bugs for the /instances call to not crash.