Move procedure to separate file. Fixes #8