Clean-up of finding the lowest lock instance

The code had a number of issues: it used slist_append, which is O(n),
making the list construction O(n**2). Finding the lowest lock was also
done in a rather non-elegant way.

Anyways, the whole list construction was needless anyway, because one
could just save the lowest lock instance integer while iterating over
the locks.