copied accross improvements and fixes fromexperiment version of the codebnase.