Clean up code and adapt to new serial API.