basic changes to fix some bugs