Improve duplicate variable checking and struct initialization