Core: moved register() to a lib.
Register: added debug output.