Added ConfigManager to preserve some values. Fixes #221. Also fixed some py2/3 and unicode encoding issues.