Full spec for D2, most prints commented, some left for debugging