Fixed NullPointerException in material handler