More warning fixes and change compilation system optimisation level to -O2