Fixed Logic Errors
Some Fixes