partial rewrite (mostly classnames, type names, etc), also added support for userpointers (though still awaiting research)