Merge code from jfryman module