Adding comments, cleaning up code