Improved upgrade script to be fully working and updated access control