Factoring out reusable bits from SCAPE-specific ones.