Initial code dump.

Everything seems to be working. Might need further testing and debugging.