Cleaned up how the base_path is determined