Rebase from Sourceforge

Rebase and merge from the sourceforge git repo to pull in the changes from Gabor's latest source dump.

This could do with some careful review.