Re-organized the code in classes using the decorator pattern