General refactoring, moved RefRestrict out of demo project