Several fixes and additions