Added timed wait for condition and replaced template callable with std::function.
Fixed stuff from previous commit.
More fixes, now everything runs.