Implement more thread-safe API/fix typos