Many changes and fixes