Adding an iteration over the layers from map

Note: Code ugly, my C++ is completely rusty, there should be smarter to
do, fiddling with references / dynamic allocations ...

TODO:
- Fix memory leaks
- references vs pointers vs statically allocated resources ?