some safety checks. collection material sorting fixed. if last material is removed from collection, it is set to draft. minor fixes