Made a bunch of changes to the way that the $() compatability code is handled.