fixed pointer problems and guard in material files

Fixed pointer guards and one incorrect assignment