Imported useful code from another project

Various code bits from other projects. Nothing works yet.
Cleaned up old code.  Ready for new project