Added checks if too many barriers are set. Also fixed code for un-setting barriers.