Extension methods and other utility functions to fill in the cracks.