cleaned up some code around process handling.