Move DBG defines to .hrl file.
Solve problems concerning global name registration.

This commit delays on_connected callbacks when visible connections
are used until the global name servers are in sync. This allows
users to use globally registered processes directly from the
on_connected callback.