Misc bugs and changes to materials_build_mode.