Updated with support for circle and loops.  Added tests for the same.