Improve error handling

We're keeping a global set of valid pointers. On constructing a tox instance, we check whether the set contains this pointer, and if it does not, throw an exception.
The set is synchronized, so all actions should be thread safe, this will need extensive unit testing however.