Major overhaul and cleanup on read and parse functions