Improved variable naming and tidied up.