Add factory method and use them everywhere. Fixes #21