table refactoring; bug fixes