Empty table catching and bug fixes