lib improvements & bugfixes