refs #2174 loads of bugfixes and improvements