Rewrite APIs to use wrapped and synchronized Client

All currently implemented APIs now use a synchronized client and a
synchronized map of all the yet-unresolved thunks. There is no
attempt made currently to ensure memory allocated is freed at the
moment.