hid api keys and cleaned up duplicate code.