fix memory initialisation bug
always clean layer
cleanup