Fixed compile errors in write metrics code