First committ. Imported some old code which will form the basis of cleaned up functions for project.