Refactoring, including use of pointers to read functions to handle arbitrary types