Simplified some checks and commented out unused code