Refactor. Add setup.py and move code into core.