Added more comments and  other bugfixes