Fix reading of scalar values

Should fix issue #396