Split logic out of bin, closes #71