First set of changes from sam

CCJ changes, first big set of changes