Fix a segfault when hiding a layer
Implement surface resizing