Add a scheduler

fixes #300