Minimal functionality achieved

This has not been tested very thoroughly, but I have at least fixed all
obvious bugs in my development configuration. It should work OK for
ordinary installations, I think.