Merge code for Stratum protocol compatibility

This is preliminary code for Stratum support.