Cleanup and back ported fixes.