Code Cleanup and more porting to 1.8