implemented merging of layers. Closes #93