split function by concern, renamed functions for clarity, cleaned up pep8 issues

This is what I get for coding after mid-night.