Added some basic loop checking.