Completely reorganize and document core.h