Move utility functions into utils

Fixes #205