Switch to pointers to fix downcasting