Fix #812: invalid internalizatin of variables into loop
Variables used in other loop should also be considered in the usage analysis.
Add test
Cleanup & add comments
Merge pull request #814 from sklam/fix_812

Fix #812: invalid internalizatin of variables into loop
Optimize flat() implementation for non-contiguous arrays.
Speed up C-contiguous flat() by 15% more by keeping track of the current pointer
(speedup should be larger on arrays with non-trivial item sizes)
Merge branch 'master' of github.com:numba/numba into flat_speedup