Several fixes and changes