Updated to work with variable spaces.