[Code Style]Clean up libraries/legacy. Fixes #4635