Added support for for-loop rewriting and fixed an issue with nested code blocks