clean up code, add docstrings, convert to class so anyone can use this thingy
fix some wierd conflict