New data layer

This PR will resolve #148 and take over #196.