Updated technical design document. Cleaned up some of the code.