Lots of fixes

Refactored, removed warning inducing code, added more config options to
build.cfg