Added loop detection & style corrections