Added conditional checks to setting up variables to prevent compiler warnings.