Refactor

Hi Yossof,

Here is some re-factoring.  I tested it with T2.

Ted