Fixed issue with metadata not beign applied because file has not yet been created. This solves #1214. This solves #1218.