Fixed inconsistencies due to duplicate domain instances.

Also fixed ordering of transactions to use the id if the transaction
dates are equal.