Rewrote config handling. It's somewhat better.