more work on main and fixes