Make code more robust, add more compiler warnings and handle warnings as errors on linux