Minor mprovements over the origial code.