Cleanup
Refactored _build_required_imports() into two separate functions