declare some volatile variables as static to allow more compiler optimizations