multiple refactors (encapsulation, readability, modularity, pep8)

should fix test breakage

Stopping from the Web UI was broken.