Porting for Ti compiler 4.4.2 and fixing optimization issues