Reinstalling X11 on Mac OS Lion So my X11 is completely messed up.

The problem started after using Octave/Gnuplot (installed through downloaded package, not MacPorts) to plot some data. After rebooting, when trying plotting again, X11 just failed to start. The icon jumped once, and then disappeared.

So I tried installing XQuartz, but I got the same problem. The Console says:

11/4/11 12:23:16.861 AM [0x0-0x272272].org.macosforge.xquartz.X11: /Applications/Utilities/XQuartz.app/Contents/MacOS/X11: line 3: dirname: command not found
11/4/11 12:23:16.938 AM [0x0-0x272272].org.macosforge.xquartz.X11: /Applications/Utilities/XQuartz.app/Contents/MacOS/X11: line 9: basename: command not found
11/4/11 12:23:16.938 AM [0x0-0x272272].org.macosforge.xquartz.X11: /Applications/Utilities/XQuartz.app/Contents/MacOS/X11: line 14: /X11.bin: No such file or directory
11/4/11 12:23:16.938 AM [0x0-0x272272].org.macosforge.xquartz.X11: /Applications/Utilities/XQuartz.app/Contents/MacOS/X11: line 14: exec: /X11.bin: cannot execute: No such file or directory
11/4/11 12:23:16.939 AM com.apple.launchd.peruser.501: ([0x0-0x272272].org.macosforge.xquartz.X11[65054]) Exited with code: 126


Then I thought that maybe I a good idea was to uninstall X11 and XQuartz completely and reinstall it from scratch (I have used a licensed copy of CleanMyMac to remove XQuartz and some Terminal commands to remove X11 related directories). Wrong. Now the installer keep saying that X11 is already installed, at a newer version and thus cannot be reinstalled.

Do you have any ideas of what's going on and how should I cope with this?

Thank you
Tunnuz
Did you delete the receipts for X11 and XQuartz?