Bug fixes (hopefully)