refactored a bit of code, more graceful shutdown, 1.0.1-RC1
more graceful shutdown sequence