Refactor structure

Fixes #48