performance, some bug fix