fixes some bugs.