Here is a list of what can be done without a problem to the e39
1999-2000 323i e46 to 2001-2003 525i
2001-2005 325i e46 to 2001-2003 525i
1998-2001 Z3 2.3i e36/7 to 2001-2003 525i
2004-2005 525i to 2001-2003 525i
1999-2000 328i e46 to 1999-2000 528i
1996-1998 328i e36 to 1997-1998 528i
2001-2005 330i e46 to 2001-2003 530i
1999-2006 X5 e53 3.0i to 2001-2003 530i
2001-2002 Z3 e36/7 3.0i to 2001-2003 530i
2004-2005 530i e60 to 2001-2003 530i
2000-2003 X5 e53 4.4i to 1999-2003 540i
1999-2001 740i e38 to 1999-2003 540i
You can upgrade your engine, but you cannot easily go from single VANOS to dual VANOS, you have to stay with what you have. If you have a 2004 530i, you can upgrade to a 3.5, but you have to use all of your existing 3.5 accessories if you do not want to go with the hassle of getting your DME aligned to your key.
If you have a 530i, you cannot really upgrade unless you swap over the wiring, engine computer, transmission, transmission computer, and get the electronics aligned to your car. It is doable, but not really worth it.