Add source installation option

This is #40 rebased on top of the latest master, with some additional cleanup and tests added.