Tileobject templates get gid = 0 in .lua

If you use one tileset for tiles and another tileset for template objects. Then all objects get a gid = 0 in the .lua file.
The problem looks to be that the template object tileset is not added to the .tmx or .lua file when you add a template that contains the tile.
One workaround i found for this is to place a tile from the template object tileset and save and then delete it.
The reason why i uses different tilesets is that they have different sizes. Like one 8x8 for my tiles and one 16x16 for my objects.