Added scope checking for return statements.