Do checks in sequence and only set CCACHE_ROOT once

Clean up code

Change-Id: I2f2fe6e33b149797944b06689ff70672b9e8e7ae