Add missing apikey function and finish merging code