Adjusts code structure and comments