Restructured code based on pylint suggestions