Set 'type' property first. Fixes #3