added functions to find sets & runs; misc improvements throughout