Refactored code and fixed reader testing.