More cleanups (needs further testing).