Multiple fixes. Cleanup code.