record statistics, fixes singleton parent, add commenting and add logging