fix some bugs; made some tweaks