file_put_contents optimizer and other fixes [ci skip]