Fixed some linker flags, warnings and optimisation.