Fixed null pointer exception when assigning traits

This fixes #30