Resolve some bugs