update comments and code cleanup