fixes as per Marco's suggestions