Refactored to pick up the code for nexec into another file.