Fixed all errors.
Added purge method.
Detect file changes when writing config file. Also write cache data.