Solving some bugs, found some new ones.