Cleaned up utility functions.