Removed unused variables and added debug toggle