use cached files if not dev env and synchronize access
cleanup & some comments