Add SDP to table conversion, with some re-organizing of functions