some comments added, warnings corrected