Refactor out sysconfig handling

OK, I will change it.