added more client comments and clarified parsing logic further