Refactoring, selection, layer rendering

Refactoring of edit operations and selection. Finished drawing logic for
layers. Added visible flag to layers. All edit operations now work for
layered maps.