Ported most of the library