Programming Open Systems with Agents, Environments and Organizations