Use Reader and Writer trait objects. Inlined some functions.