Refactor and remove logging