initial import of the library from a personal project, it already have some minor changes from the original