Added code descriptions, main loop, etc