JBIDE-13896 with denis' suggested changes