Fixed bugs in custom-python code