A lot of fixes by Javier