A number of fixes (thanks to Mike)