Several changes and fixes