Fixed some bugs and sorted out SIGHUPping