Only define struct+function if needed. Resolves issue #1