manual merge of some bug fixes