Made factor.py a little more elegant, added a few comments.