Some library fixes