cleaned up code, fixed bug with config

fixed bug with config.