Util cleanup and refactoring