Added support for material colors and fixed several possible crashes.