moved more stuff into sys-*.c