fixed recursion with has and belongs to many. added sql logger.