Fix some bugs inside migration and filtering materials