refactored and updated a lot of this, works well now with redhat and debian systems
removing quick debugging stuff