More improvements by suggestions from Joakim Plate