JBIDE-13896 with denis' suggested changes
JBIDE-13207 - small cleanup
JBIDE-13959 and JBIDE-9830