Use class inheritance instead of lambdas, I measured the performance to
be slightly better