Added support for refreshing materials, fixed access violation on reload.