separated the C source and headers
Working state, fixed a minor race condition on exit.
Small changes to the to the readme.