Added function documentation and integer casts to removed signed-unsigned comparison warnings