Big changes in core.c for almost-Windows building