Modified to enable script driven shell execution, a series of small bug fixes to prevent problems