Restructured code for easier extensibility