re-merging locking and star/unstar code