Major rewrite & cleanup of SATO code