Cleaned things up. Added more comments.