Fix deriving of indexed data types