Fix some bugs and limitations