Fix layout compatibility and Add data encryption