Fixed additional scope ambiguities. Removed unused variables.