Removed redundant code and tidied up comments