Bug fixes (previous commit broken)