Started porting working code