Cleaned up factoring, turned core into a proper set