converted many prints to logging calls; refactor more file access operations to use shared utility function.