Fix "Fatal error: Using $this when not in object context"