fixed memory scheme, added missing library functions