fixed charref handling
Remove redundant switches
auto-merge staging into master