many small fixes, should be reviewed