Fixing some params and logic bugs
merge conflicts