Improve library backend and api. Now also using a queue for stat.