made a few fixes, while I'm still trying to figure out the bugs I'm seeing.