Core prototyping

Slightly cleaned up prototype code to work as basis for everything else.