Moved code from cepl to here.
Will complete work on time separately