Added the core functionality

Not quite there yet, but close.