manual merge from 0.10
cleanup of some code