Added a material manager and made materials thread safe.
Also removed the bitwise parameters. They are replaced with appropriate getters and setters. #792