updated source.

some of the code doesn't look right, will test.