Add comments and fix compiler warnings