Some minor bugs in functions.py vs