restructuring and added table.c for quanta manipulation