start to merge good parts of dimple_layer branch