Added tox setup, fixed a few bugs.