Minor fixes, also added an index for checking if a match is already in the database