Upgraded version comparison code to be a bit more robust.