Improved the material selection code.
Started work on changing material color
fixed some bugs.