Utility functions and classes