Various changes and fixes