Empty table safety
Fix
Safety
Fixes and refactorings