Refactor key and element types to the Abstract class