Working

Needs comments and cleaning up.