Factored out tie-breaking code into its own file