PCD reader and writer refactored