fix metadata template, add more debugging

Change-Id: Id39a1834c08d9afcd5466a9ff0ffc3c091333f54