Fixed some errors with logic.