Cleaned up for PEP8 standards, and added a few code efficiency improvements.