Big refactor into smaller bitsize modules, and adding a setup.py