added some comments
fixed some compiler warnings