Refactor floobits.py