added more comments, removed some extraneous bits