fixed some leaky cursors

moved LibraryUpdateTask operations into a transaction for quite the
speedup

Cleaned up imports