Updated to use common code in tk-mari engine