Clean up const usage to avoid excessive casting