Some fixes after debugging - dont know if this makes sense...