Fully working version
Added missing declaration for dt
Open phil branch