Add original code from Shai.