fixes some bugs