Various fixes to update the package and make it more robust