bug fixes, error checking in 'read'