Rewrote chat target handling and some more cleanup.