Various fixes according to Luigi suggestions