Make getter and setter more robust