various fixes for typing of index expression
fix typing problems in #569