Minor refactoring
Allow running of arbitrary functions