Fixed various logic