Added weighing and fixed OR search.