Moved utility functions into a separate module.