Modular approach

Pull request for issue #88.

(Sorry, tried to convert other issue into pull request, but I got a 500 error from github. Maybe I'm not doing it right.)