Re-organizing code a bit, adding comments.