Integrate Cezary's additions and work some more on it.