something is still broken
making some of the variables volatile
a little more code cleanup