Initial code dump

Everything works for D=2, but the code is not in it's most user-friendly
form.