Escaping spaces and fixing scoping issues