Fixes for empty files and assertion for invalid tables

Now separated into two commits.