Cleaned up ProcessIO() so it is as generic as possible
updated