Fix shape superposition check, and other minor things