Finalized code and comments