removing empty spaces + making applyFromDict a bit safer