several fixes after reviews from Victor