Add full structure, fix some bugs.