Initial commit.

This somewhat works. Not extensively tested, though.