Cleanup a little bit and integrate Cezary's changes.