Clean up APIkey stuff and add link stats

Link stats is not complete.
Actually, I haven't written any of these API functions yet now that I think about it...