fixed some version compatability issue
some cleaning up