various bug fix, should be stable now