Fixed some warnings and added a few comments.