Split some functionality into utils module