Library cleanup, some other fixes.