SDM: Code cleanup part 2: shape alignment, model variance calculations