gradient handling, several smaller improvements or bug fixes