merged a little with yuki branch