Split into copy and pasteable functions. Fixes #27