Add comments, improve formatting