Cleaned up lastest good-working code and added some initial structures for libconfig support.