Attempt to fix some bugs