Better substituion variables and fix whitespaces