Refactor CFFI implementation

Replace singleton pattern with just using straight functions.