Finish adding logic for config.
Start fixing some logic bug.