moved magic into structure (mainly to simplify the client code)
added missing API hooks
2 files changed