Various changes to make it work