More helper functions.

Nearly done!