Refactor utils

Move a number of generic utility functions and methods to a Utils class for improved/consistent access to them and maintainability.