Add comments and clean up formatting