Fixed stage ref bug
Merge bugfix from 'dev'