Fixed stupid syntax and logic errors