Upstream

* Fix apply_cache permission issue
* Enable compiling in c99 and extra warnings.