Updated some reference state functions, does not work properly at the moment.
Fixed the broken reference state setter function