Refactors bus code