[PATCH 1/3] Fix nesting and environment issues