Fixed merge bugs. Fixed all warnings, there are TODOs to remove warning
avoiding code.