Implement custom c function again after refactoring

Re-introduced cookie for c functions (pointer to anything).
Moved actual function registration right after the built
in functions are registered.