Fix metadata loader loading incorrect masks
Update metadata sql.