Fixed some bugs in acc. with Alex comments