Move idle calculation into lib, wip