Implement helper functions and data structures