fix math.h include directives

Should be #include <math.h>, not #include "math.h", (we don't have our own math.h)
Add some needed header file dependencies

An improvement, but probably not complete, and there's probably a smarter way