re-adding comments, adding casts to get rid of compiler warnings