Several changes to make it work