Add various missing bits of code