enable cleanup at END and fix double -lm