more fixes to layer upload, but still needs more work