Redmine#5650: clean up expression logic