Enhancements to make more robust and added support for init scripts etc