Fixes some bugs.