Fix build flags and use -DNDEBUG in release builds