Cleaned up table code