Several fixes + improvements