Untested final version.

Multiple errors fixed and the entire structure is set. Only thing left
is to include a makefile and test.