Use temp variables to avoid repeated actions in code.

Not that it makes code faster but it makes code lines a bit shorter and a bit more readable.