Add type hinting to defwrapper, clean up core