Some bug fix, adding new features: shutdown and restart