many changes and fixes