Several changes to fix errors