Fixed some loopholes