Custom input format, take 2

This represents a somewhat cleaned up version of #22, based upon the changes in #23. All changes on top of #23 are in the commit 9d328ac778a57a581ee715f9793391780f61a6b9.