Refactor data layer step 5

Depends on #300 

Not ready yet, pushing for travis.