function in case of broken sysconfig. fix #1074

PR #1075 plus some fixes to pass travis.