Added logging, refactored Utils.