Fixing some bugs; changing a few variable names