Document all the types

Adds type specification for mostly all of the functions and classes in core/, except for loader, and irc.