Cleaning up and preparing for layers

Running dialyzer shows a lot of todo's