Return values as OrderedDict to make referencing easier.
Added ratio detection in the width and height swapping code