Fix calls to local functions and fix toggle bug