cleanup use of internal variables

- use M_PI from math.h
- make some global variables privat