Core: Use RecMutexs instead of thread local variables

Avoid clash when a thread started by the Core try to access to cb_data
(which is unset as the data is thread local).
Core: Make cb_data handling internal

It will allow interfaces handling the core to encapsulate teir calls to
the the core's callbacks, avoiding it to try to access unset cb_data.
retro-environment: Correct calls to set_message() and set_shutdown()

The first parameter (the Core) was lacking in the calls.