In terms of closing tax loopholes: tax loopholes are like vulnerabilities in software. They will always exist despite the best effort of lawmakers (programmers, in this analogy). The difference is that lawyers (hackers) don't go to jail for finding and exploiting loopholes.
In my opinion the root of this problem is the legal profession. The practice of law seems almost irreparably broken to me. Money should not have relevance in a courtroom, but it obviously does, it always has, and it will continue to. I have no clue how to fix this, but I think it's a huge problem in liberal western democracies whether it's patent trolling, Apple/X megacorp employing an army of layers to avoid paying taxes, or Harvey Weinstein/Bill Cosby committing sexual assault/rape over and over again without ever visiting a jail cell.