Refactor tray stuff