Refactored H-bridge code.