Refactoring. Add table models and gui.