join works lol
seems that everything works
fixes in flat table
some clean up in code